home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
FromTheMag
/
JW FLV MEDIA PLAYER 4.2
/
mediaplayer.exe
/
player.swf
/
scripts
/
com
/
jeroenwijering
/
utils
/
Stretcher.as
< prev
next >
Wrap
Text File
|
2008-11-04
|
2KB
|
67 lines
package com.jeroenwijering.utils
{
import flash.display.DisplayObject;
public class Stretcher
{
public static var EXACTFIT:String = "exactfit";
public static var FILL:String = "fill";
public static var NONE:String = "none";
public static var UNIFORM:String = "uniform";
public function Stretcher()
{
super();
}
public static function stretch(param1:DisplayObject, param2:Number, param3:Number, param4:String = "uniform") : void
{
var _loc5_:Number = NaN;
var _loc6_:Number = NaN;
_loc5_ = param2 / param1.width;
_loc6_ = param3 / param1.height;
switch(param4.toLowerCase())
{
case "exactfit":
param1.width = param2;
param1.height = param3;
break;
case "fill":
if(_loc5_ > _loc6_)
{
param1.width *= _loc5_;
param1.height *= _loc5_;
}
else
{
param1.width *= _loc6_;
param1.height *= _loc6_;
}
break;
case "none":
break;
case "uniform":
if(_loc5_ > _loc6_)
{
param1.width *= _loc6_;
param1.height *= _loc6_;
}
else
{
param1.width *= _loc5_;
param1.height *= _loc5_;
}
}
param1.x = Math.round(param2 / 2 - param1.width / 2);
param1.y = Math.round(param3 / 2 - param1.height / 2);
param1.width = Math.ceil(param1.width);
param1.height = Math.ceil(param1.height);
}
}
}